package ui.mini_fragments

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.awt.SwingPanel
import androidx.compose.ui.unit.dp
import models.PDFImageModel
import ui.widget.PDFImage
import java.awt.Canvas
import java.awt.image.BufferedImage

@Composable
fun PDFImageView(image: PDFImageModel,onImageSelected : (BufferedImage) -> Unit) {
    Row(
        horizontalArrangement = Arrangement.Start,
        verticalAlignment = Alignment.CenterVertically,
        modifier = Modifier.fillMaxWidth()
            .clickable { onImageSelected(image.image) }
    ) {
        SwingPanel(modifier = Modifier.size(25.dp), factory = {
            PDFImage(image.image)
        })
        Text(image.name)
    }
}